<template>
	<view class="content">
		<view v-if="adminInfo.isSeller">
			<view class="seller">
				<view class="left">公司名称：</view>
				<view class="right">{{ sellerInfo.companyName }}</view>
			</view>
			<view class="seller">
				<view class="left">统一社会信用代码：</view>
				<view class="right">{{ sellerInfo.companyCode }}</view>
			</view>
			<view class="seller">
				<view class="left">联系人：</view>
				<view class="right">{{ sellerInfo.contactName }}</view>
			</view>
			<view class="seller">
				<view class="left">联系人手机号：</view>
				<view class="right">{{ sellerInfo.contactMobile }}</view>
			</view>
			<view class="seller">
				<view class="left">认证资料：</view>
				<view class="right">
					<image class="logo" :src="item.url" v-for="(item,index) in sellerInfo.companyImg" @click="showImg(index)"></image>
				</view>
			</view>
		</view>
		<view v-else>
			<view class="no-apply" v-if="JSON.stringify(sellerInfo)=='{}'">
				<view>还未进行商家认证，快去提交认证信息，享受更多优惠价格...</view>
				<button type="primary" @click="toSellerApply()">提交认证信息</button>
			</view>
			<view class="applying" v-else-if="sellerInfo.checkStatus == 0">
				<view>平台审核中，请耐心等待审核结果...</view>
				<button type="primary" @click="back()">返回</button>
			</view>
			<view class="no-apply" v-else-if="sellerInfo.checkStatus == 2">
				<view>商家认证被拒绝，详细信息：</view>
				<view><text style="color:#F00; font-weight:bold;">{{sellerInfo.rejectReason}}</text></view>
				<button type="primary" @click="toSellerApply()">去修改</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		accountApis
	} from '@/pages/apis/user/account.js'

	import {
		CONFIG
	} from '@/pages/config.js'

	import {
		isLogin
	} from '@/pages/utils/common.js'

	export default {
		data() {
			return {
				Config: this.$Config,
				Common: this.$Common,
				Auth: this.$Auth,
				ShareUtil: this.$ShareUtil,
				State: this.$store.state,
				Dict: this.$Dict,
			
				sellerInfo: {},
				adminInfo: {}
			}
		},
		onLoad() {
			this.initPage()
		},
		methods: {
			initPage() {
				if (isLogin()) {
					this.adminInfo = uni.getStorageSync('UserInfo')

					this.getInfo()
				}
			},

			getInfo() {
				accountApis.getSellerInfo({}).then((response) => {
					if (response != null) {
						response.companyImg = JSON.parse(response.companyImg)
						this.sellerInfo = response
					}
				})
			},
			toSellerApply() {
				uni.navigateTo({
					url: '/pages/ucenter/SellerApply'
				});
			},
			showImg(index) {
				let urls =[]
				this.sellerInfo.companyImg.forEach(item=>{
					urls.push(item.url)
				})
				uni.previewImage({
					urls: urls,
					current:index
				});
			},
			back(){
				uni.navigateBack({delta: 1})
			}

		}
	}
</script>

<style lang="scss">
	.content {
		padding: 20px 15px 15px 15px;
		font-size: 32rpx;
	}

	.no-apply view {
		margin-bottom: 30px;
		text-align: center;
	}

	.applying {
		padding: 20px;
	}
	.applying view {
		margin-bottom: 30px;
		text-align: center;;
		padding: 30px 20px;
	}

	.seller {
		display: flex;
		border-bottom: 1px solid #eee;
	}

	.seller .left {
		flex: 8;
		padding:10px 10px 10px 0;
	}

	.seller .right {
		flex: 16;
		padding: 10px 0;
	}

	.seller .right image {
		width: 50px;
		height: 50px;
		margin-right: 10px;
	}
</style>
